﻿<%@ Page Language="C#" MasterPageFile="~/Home/ad/admin.master" AutoEventWireup="true" CodeFile="ad_sp.aspx.cs" Inherits="Home_ad_ad_sp" Title="Welcome to IT" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
    <br />
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
<asp:Label ID="Lbloi" runat="server" Text="" CssClass="styles16" ForeColor=red></asp:Label>
        <asp:Label ID="Lbtb" runat="server" Text="" CssClass="styles30"></asp:Label>
<table align=center width=100%>
    <tr valign=top>
    <td valign=top style="width: 89px">
        &nbsp;
        
    </td>
    <td valign=top style="width: 153px">
        
    </td>
        
    </tr>
    <tr>
    <td style="width: 89px">&nbsp;</td>
        <td style="width: 153px">Danh mục sản phẩm</td>
        <td>
            <asp:DropDownList ID="Dropdmsp" runat="server" OnSelectedIndexChanged="Dropdmsp_SelectedIndexChanged" AutoPostBack="false">
                
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
    <td style="width: 89px; height: 5px;">&nbsp;</td>
    <td style="width: 153px; height: 5px;">
        Tên sản phẩm
     </td>
    <td valign=top style="height: 5px">
            <asp:TextBox ID="txtsp" runat="server" MaxLength="200"></asp:TextBox>
            <asp:Button ID="add_sp" runat="server" Text="Thêm sản phẩm" OnClick="add_sp_Click" /><br />
            &nbsp;<br />
    </td>
    
    </tr>
    <tr>
        <td style="height: 4px; width: 89px;">
           
         </td>
        <td style="height: 4px; width: 153px;">
            Chọn tên danh mục
           
            </td>
            <td style="height: 4px">
                &nbsp;
                 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db_connection %>"
                SelectCommand="SELECT * FROM [DM001] ORDER BY [DienGiai]"></asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:db_connection %>"
                SelectCommand="SELECT [ID], [DienGiai] FROM [DM002] WHERE ([ID_DM001] = @ID_DM001) ORDER BY [ID]" DeleteCommand="DELETE FROM [DM002] WHERE [ID] = @ID" InsertCommand="INSERT INTO [DM002] ([DienGiai]) VALUES (@DienGiai)" UpdateCommand="UPDATE [DM002] SET [DienGiai] = @DienGiai WHERE [ID] = @ID">
                <SelectParameters>
                    <asp:ControlParameter ControlID="DropDownList1" Name="ID_DM001" PropertyName="SelectedValue"
                        Type="Int32" />
                </SelectParameters>
                <DeleteParameters>
                    <asp:Parameter Name="ID" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="DienGiai" Type="String" />
                    <asp:Parameter Name="ID" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="DienGiai" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
                DataTextField="DienGiai" DataValueField="ID">
            </asp:DropDownList>
            </td>
    </tr>
</table>
   <table align=center width=100%>
   <tr>
    <td style="width: 14%">&nbsp;</td>
    <td>
        &nbsp;<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlData_spspspsspsps"
            Width="347px">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="M&#227;" InsertVisible="False" ReadOnly="True"
                    SortExpression="ID" />
                <asp:BoundField DataField="DienGiai" HeaderText="Loại sản phẩm" SortExpression="DienGiai" />
                <asp:CommandField ButtonType="Button" CancelText="[Hủy bỏ]" EditText="[Sửa]" ShowEditButton="True"
                    UpdateText="[Cập nhật]" />
                <asp:CommandField ButtonType="Button" DeleteText="[X&#243;a]" ShowDeleteButton="True" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlData_spspspsspsps" runat="server" ConnectionString="<%$ ConnectionStrings:db_connection %>"
            DeleteCommand="DELETE FROM [DM002] WHERE [ID] = @ID" InsertCommand="INSERT INTO [DM002] ([DienGiai]) VALUES (@DienGiai)"
            SelectCommand="SELECT [ID], [DienGiai] FROM [DM002] WHERE ([ID_DM001] = @ID_DM001) ORDER BY [ID]"
            UpdateCommand="UPDATE [DM002] SET [DienGiai] = @DienGiai WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="DienGiai" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="ID_DM001" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="DienGiai" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    
   
    </td>
   </tr>
   
   </table>
   

</asp:Content>

